#pragma once

#include <d3d9.h>
#include <d3dx9.h>
#include <cmath>
#include "../Local.h"
#include "../XenMemory/XenMemory.h"
#include "../Input.h"

void myCreateTexture(LPDIRECT3DDEVICE9, LPCTSTR, LPDIRECT3DTEXTURE9);

class XenStats
{
private:
	XenMemory *xenMemory;

	IDirect3DDevice9 *pIDirect3DDevice9;

	int screenWidth;
	int screenHeight;
	float scaleX;
	float scaleY;

	short maxHp;
	short maxMp;

	static char displayStats;

	D3DXFONT_DESC fStats;

#define STATSARC_LOC  "xenergy/images/arc.png"
	LPDIRECT3DTEXTURE9 hpTopArcTexture;
	LPDIRECT3DTEXTURE9 hpBottomArcTexture;
	LPDIRECT3DTEXTURE9 mpTopArcTexture;
	LPDIRECT3DTEXTURE9 mpBottomArcTexture;
	LPDIRECT3DTEXTURE9 xpTopArcTexture;
	LPDIRECT3DTEXTURE9 xpBottomArcTexture;
	LPD3DXSPRITE arcSprite;

	//Stats Background
#define STATSBG_LOC  "xenergy/images/statsbg.bmp"
	LPDIRECT3DTEXTURE9 statsBgTexture;
	LPD3DXSPRITE statsBgSprite;

	//Stats HP
#define STATSHP_LOC  "textures/lava.bmp"
	LPDIRECT3DTEXTURE9 statsHpTexture;
	LPD3DXSPRITE statsHpSprite;
	LPD3DXFONT statsHpFont;

	//Stats MP
#define STATSMP_LOC  "textures/water.bmp"
	LPDIRECT3DTEXTURE9 statsMpTexture;
	LPD3DXSPRITE statsMpSprite;
	LPD3DXFONT statsMpFont;

	//Stats MP
#define STATSXP_LOC  "textures/imt2.bmp"
	LPDIRECT3DTEXTURE9 statsXpTexture;
	LPD3DXSPRITE statsXpSprite;
	LPD3DXFONT statsXpFont;

	void RenderBar(float percent, bool left, byte r, byte g, byte b, D3DXVECTOR2 arcPos, LPDIRECT3DTEXTURE9 topArcTexture, LPDIRECT3DTEXTURE9 bottomArcTexture, bool redraw, float scale = 1, float rotationAngle = 0);
	void RenderArc(float angle, bool top, bool left, byte r, byte g, byte b, D3DXVECTOR2 arcPos, LPDIRECT3DTEXTURE9 arcTexture, bool redraw, float scale = 1, float rotationAngle = 0);
public:
	XenStats(IDirect3DDevice9 *pIDirect3DDevice9);

	void Initialize();
	void Render();
	void RenderNewStats();
	void RenderOldStats();
	void ProcessInput();
	void Release();
};